/*
ONEGAME
Copyright (C) 2009  Pablo Caballero

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package one.language;

import java.util.ResourceBundle;

/**
 * Facade of the label system
 * @author Pablo Caballero
 * @version 1.0 24-jun-2009
 */
class ConnectorProperties {

	/**
	 * The reference to the internacionalization
	 */
	private ResourceBundle bundle = null;
	/**
	 * The path to the resource
	 */
	protected String path;

	/**
	 * Constructor
	 * @param path the path to the resource
	 */
	ConnectorProperties(String path) {
		setPath(path);
	}

	/**
	 * Get the value of the path to the resource
	 * @return the value of path
	 */
	public String getPath() {
		return path;
	}

	/**
	 * Set the value of path
	 * @param path new value of the path to the resource
	 */
	public void setPath(String path) {
		this.path = path;
	}

	/**
	 * Prepares the internacionalization
	 */
	protected void prepareBundle() {
		if (bundle == null) {
			bundle = ResourceBundle.getBundle(getPath()); // NOI18N
		}
	}

	/**
	 * Gets the string associated with the key
	 * @param key the key of the property
	 * @return the label, if it doesn't exist or is the key is null will return null
	 */
	public String getString(String key) {
		if (key == null || key.length() == 0) {
			return null;
		} else {
			prepareBundle();
			return bundle.getString(key);
		}
	}
}
